Introduction to Cryptography

Introduction

Cryptography is about protecting information.
People have been hiding messages for thousands of years, from ancient generals to modern internet users.

This article explores:

What Is Cryptography? A Gentle Overview

Cryptography helps us:

Two broad eras:

The Caesar Cipher: Shifting Letters, Shifting Meanings

The Caesar cipher shifts each letter by a fixed amount.

How it works:

Example with shift 3:

Why it’s important:

Why it’s weak:

Substitution Ciphers: Swapping Letters With a Secret Key

A substitution cipher replaces each letter with another letter.

Key features:

Strengths:

Weaknesses:

Transposition Ciphers: Rearranging Instead of Replacing

Instead of changing letters, a transposition cipher reorders them.

Examples:

Strengths:

Weaknesses:

Example: The fixed columnar transposition cipher

Encryption

Given the text "Hello, World!", we write this row-by-row, in a grid with 3 columns:

Hel
lo,
Wo
rld
!

We then read it column-by-column to get "Hl r!eoWll,od".

Decryption

Decryption is simply reversing the steps above:

  1. Write the text column-by-column
  2. Read row-by-row

Permutation keys

A permutation key is simply a reordering of the column indices in a columnar transposition cipher.

If you have $ n $ columns, the “natural” order is: $$0, 1, 2, 3, \dots n‑1$$ A permutation key is any rearrangement of these numbers, for example: $$2, 0, 3, 1$$ This tells the cipher:

So if the key is $[2,0,3,1]$, you read:

  1. column 2
  2. column 0
  3. column 3
  4. column 1

This is what makes the cipher actually keyed.
Without a permutation, the cipher is deterministic and predictable.

Double transposition

A double transposition cipher applies two columnar transpositions in sequence, each with its own permutation key.

It was used extensively in WWII because it’s surprisingly strong for a hand cipher.

How it works

  1. First transposition
    • Write plaintext into a grid
    • Read columns in the order of key 1
  2. Second transposition
    • Take the output of step 1
    • Write it into a new grid
    • Read columns in the order of key 2

Why it’s powerful

A single transposition is easy to break with modern frequency analysis.
A double transposition is much harder because:

Book Ciphers: Using a Shared Text as the Key

A book cipher uses a publicly available book as the secret key.

How it works:

Advantages:

Disadvantages:

Fun fact:

Frequency Analysis and the Limits of Classical Ciphers

Languages have patterns.
In English, for example:

Frequency analysis:

Why classical ciphers fail:

The Navajo Code Talkers: Language as Encryption

During World War II, the United States Marine Corps used Navajo speakers to create an unbreakable communication system.
This wasn’t a cipher in the usual mathematical sense — it was a code based on a language that was:

Why Navajo Was Chosen

Several features made Navajo ideal:

These properties made it resistant to codebreaking techniques used by enemy cryptanalysts.

How the Code Worked

The system combined:

Examples (simplified for teaching):

This created a double layer:

  1. You had to understand Navajo
  2. You had to know the special codebook meanings

Why It Was So Effective

Impact

The Birth of Modern Cryptography

Modern cryptography emerged when:

Key developments:

Modern cryptography focuses on:

Public‑Key Cryptography: A Conceptual Introduction

Public‑key cryptography changed everything.

Basic idea:

Why this works:

Examples of one‑way ideas:

This allows:

Calculator

Caesar Cipher

  • Encrypts and decrypts text using the caesar cipher.
encrypted = caesarCipher('Hello, World!', 3) caesarCipher(encrypted, -3)

Substitution Cipher

  • Encrypts and decrypts text using a substitution cipher.
key = substitutionGenerateKey() encrypted = substitutionEncrypt("Hello, World!", key) substitutionDecrypt(encrypted, key)

Transposition Cipher

  • Encrypts and decrypts text using a fixed columnar transposition cipher.
encrypted = fixedColumnarTranspositionEncrypt("Hello, World!", 3) fixedColumnarTranspositionDecrypt(encrypted, 3)

Exercises

  1. Encode With a Caesar Cipher

    Choose a shift between 1 and 10.
    Encode the message:

    MEET ME AT MIDNIGHT

    Write down:

    • Your chosen shift
    • The encoded message

    Solution

    Encode With a Caesar Cipher

    Example with shift 7:

    • MEET ME AT MIDNIGHT
    • TLLA TL HA TPKKPONA
  2. Break a Caesar Cipher by Brute Force

    The following message was encoded with a Caesar cipher, but the shift is unknown:

    WKLV LV D VHFUHW

    Tasks:

    • Try all possible shifts
    • Identify which decoded version makes sense
    • State the shift used

    Solution

    Break a Caesar Cipher by Brute Force

    Ciphertext: WKLV LV D VHFUHW

    Trying all shifts, the meaningful plaintext appears at shift 3:

    • THIS IS A SECRET
  3. Frequency Analysis Warm‑Up

    Here is a ciphertext created with a Caesar cipher:

    KHOOR ZRUOG

    Tasks:

    • Count how often each letter appears.
    • Try all possible shifts or use your intuition about common words.
    • Find the plaintext message and the shift used.

    Solution

    Frequency Analysis Warm‑Up

    Ciphertext: KHOOR ZRUOG

    If you try shifting letters backward by 3:

    • K → H
    • H → E
    • O → L
    • O → L
    • R → O

    So KHOOR becomes HELLO.

    Similarly:

    • Z → W
    • R → O
    • U → R
    • O → L
    • G → D

    So ZRUOG becomes WORLD.

    Plaintext: HELLO WORLD
    Shift used: 3 (each letter was shifted forward by 3 to encrypt).

  4. Create Your Own Substitution Cipher

    Design a substitution alphabet (a mapping from A–Z to A–Z).
    Then:

    • Encode a short sentence
    • Swap papers with a partner (or imagine a partner)
    • Try to decode each other’s messages

    Solution

    Create Your Own Substitution Cipher

    A complete substitution alphabet

    PlainABCDEFGHIJKLM
    CipherQWERTYUIOPASD
    PlainNOPQRSTUVWXYZ
    CipherFGHJKLZXCVBNM

    An encoded sentence

    Suppose we chooses the plaintext:

    MEET ME AT NOON

    Using the example alphabet above:

    • M → D
    • E → T
    • E → T
    • T → Z

    So MEET becomes DTTZ.

    Continuing:

    • ME → DT
    • AT → QZ
    • NOON → FGGO

    Final ciphertext:

    DTTZ DT QZ FGGO

    A decoding attempt

    To decode, we must reverse the mapping.
    Using the same example:

    • D → M
    • T → E
    • Z → T
    • Q → A
    • F → N
    • G → O

    Decoding DTTZ DT QZ FGGO returns:

    MEET ME AT NOON

  5. Break a Substitution Cipher

    Decode the following message, which uses a simple substitution cipher:

    UIJT JT B TFDSFU NFTTBHF

    Hints:

    • Look for common short words
    • Try guessing common letters like E, T, A
    • Think about patterns like double letters

    Solution

    Break a Substitution Cipher

    Ciphertext: UIJT JT B TFDSFU NFTTBHF

    This is a classic example of a shift of +1 (each letter moved forward one).

    Decoding:

    • UIJT → THIS
    • JT → IS
    • B → A
    • TFDSFU → SECRET
    • NFTTBHF → MESSAGE

    Plaintext: THIS IS A SECRET MESSAGE

  6. Try a Transposition Cipher

    Write the message:

    THE TREASURE IS BURIED HERE

    into a grid with 4 columns, filling rows left to right.
    Then:

    • Read the message column by column
    • Write down the ciphertext
    • Try reversing the process to decode it again

    Solution

    Try a Transposition Cipher

    Message: THE TREASURE IS BURIED HERE

    Write in 4 columns:

    THE
    TREA
    SURE
    IS
    BURI
    EDH
    ERE

    Read column‑by‑column:

    TTSBEE
    HRUIUDR
    EERSRE
    AEIH

    Ciphertext:
    TTS BEEHRUIUDREERSR E AE IH

    (Spacing optional.)

    Decoding reverses the process by refilling the grid column‑by‑column.

  7. Break a Transposition Cipher

    The following was encoded using a fixed columnar transposition (unknown number of columns):

    LKNRHTEO D EROUET E

    Try to reconstruct the original message by:

    • Testing different column counts
    • Looking for meaningful word fragments

    Solution

    Break a Transposition Cipher

    Ciphertext: LKNRHTEO D EROUET E

    Trying different column counts, 3 columns produces readable text.

    Reconstructing the grid and reading row‑by‑row yields:

    LOOK UNDER THE TREE

  8. Compare Cipher Strengths

    For each of the following ciphers, write one sentence explaining how you might try to break it:

    • Caesar cipher
    • Substitution cipher
    • Transposition cipher
    • Book cipher

    Solution

    Compare Cipher Strengths

    Sample answers:

    • Caesar cipher — Try all 26 shifts.
    • Substitution cipher — Use frequency analysis and common word patterns.
    • Transposition cipher — Test different grid sizes and look for meaningful fragments.
    • Book cipher — Identify the book; without it, decoding is extremely difficult.